<?php
namespace app\index\model;
use think\Model;

class Zodiac extends model{
	function findall(){
		$res = $this->select();
		return $res;
	}
	function findid($id){
		$res = db('zodiac')->where('id',$id)->find();
		return $res;
	}
	function likename($name){
		$res1 = db('zodiac')->where('sx','like',"%,".$name.",%")->find();
		if(!$res1){
			$res2 = db('zodiac')->where('sx','like',"%,".$name)->find();
			if(!$res2){
				$res3 = db('zodiac')->where('sx','like',$name.",%")->find();
				if(!$res3){
					$res4 = db('zodiac')->where('sx','like','0'.$name.",%")->find();
					// if(!$res4){
					// 	$res5 = db('zodiac')->where('sx','like','0'.$name.",%")->find();
					// }
					return $res4['name'];
				}
				return $res3['name'];
			} 
			return $res2['name'];
		}
		return $res1['name'];
	}
}